import React, {useEffect, useState} from 'react';
import {Button, Table, Tag} from 'antd';

function ReturnReviewList(props) {

  const [columns, setColumns] = useState([
    {
      title: '订单号',
      dataIndex: 'order_no',
      key: 'order_no'
    }, {
      title: '供应商',
      dataIndex: 'vendor_name',
      key: 'vendor_name'
    }, {
      title: '创建时间',
      dataIndex: 'create_at',
      key: 'create_at'
    }, {
      title: '产品名称',
      dataIndex: 'goods_title',
      key: 'goods_title'
    }, {
      title: '状态',
      key: 'review',
      render: (text, record) => {
        // review === 1 未审核
        return <div className='BeforeOperatedAction'>
          {
            text.review === 1 && <Tag size='small' color={'gold'}>未审核</Tag>
          }
          {
            text.review === 2 && <Tag size='small' color={'green'}>已审核</Tag>
          }
        </div>;
      }
    }, {
      title: '退货审核操作',
      key: 'action',
      render: (text, record) => {
        // review: 1
        return <div className='BeforeOperatedAction'>
          <Button size={'small'} type={'default'} onClick={() => props.viewDetails(text.refund_no)}>查看详情</Button>
          {
            text.review === 1 &&
            <Button size={'small'} type={'danger'} onClick={() => props.throughAuditing(text.refund_no)}>通过审核</Button>
          }
        </div>;
      }
    }

  ]);

  return (
    <div className={'SupplierOrderList'}>
      <Table dataSource={props.returnReviewList} columns={columns} pagination={false}/>
    </div>
  );
}

export default ReturnReviewList;
